<template>
    <div class="notice">
        <div class="title">{{title}}</div>
        <div class="content" @click="toUrl">
            {{message}}
        </div>
        <div class="closeButton" @click="closeNotice">
            <i class="el-icon-close"></i>
        </div>
    </div>
</template>

<script>
import {updateAgencyStatus} from "@/api/agency";

export default {
    name: "notice",
    data(){
        return{
            noticeShow:false,
            type:"alertNotice",
            title:'',
            message:'',
            time:0,
            ucId:'',
            resolve: '',
            reject: '',
            promise: '' // 保存promise对象
        }
    },
    mounted(){
       if (this.time>0){
           setTimeout(() => {
               this.$destroy(true);//3s后进行销毁
               this.$el.parentNode.removeChild(this.$el);
           },this.time);
       }
    },
    methods:{
        closeNotice(){
            this.$destroy(true);
            this.$el.parentNode.removeChild(this.$el);
        },
        cancel(){
            this.noticeShow = false;
            this.reject('cancel');
            this.remove();
        },
        toUrl(){

        },
        remove: function () {
            setTimeout(() => {
                this.destroy();
            }, 300);
        },
        destroy: function () {
            this.$destroy();
            document.body.removeChild(this.$el);
        }
    }
}
</script>

<style lang="less" scoped>
    .notice{
        position: fixed;
        bottom: 30px;
        right: 50px;
        color: #333;
        width: 18%;
        box-sizing: border-box;
        border-radius:5px;
        padding: 10px;
        background-color: #fff;
        z-index: 9999;
        cursor: pointer;
        animation: shake 1s infinite;
        .title{
            font-weight: 700;
            font-size: 16px;
            color: #303133;
            margin: 0;
        }
        .content{
            font-size: 14px;
            line-height: 21px;
            margin: 6px 0 0;
            color: #606266;
        }
        .closeButton{
            position: absolute;
            top: 18px;
            right: 15px;
            cursor: pointer;
            color: #909399;
            font-size: 16px;
        }
    }

    @keyframes shake { /* 水平抖动，核心代码 */
        10%, 90% { transform: translate3d(-1px, 0, 0); }
        20%, 80% { transform: translate3d(+1px, 0, 0); }
        30%, 70% { transform: translate3d(-1px, 0, 0); }
        40%, 60% { transform: translate3d(+1px, 0, 0); }
        50% { transform: translate3d(-1px, 0, 0); }
    }
    @keyframes mymove {
        50% {top: 300px;}
    }
</style>